//字符函数库 cctype
//using the ctype.h library
#include <iostream>
#include <cctype>
int main()
{
    using namespace std;
    cout << "Enter text for analysis, and type @"
            " to terminate input.\n";
    char ch;
    int whitespace = 0;
    int digits = 0;
    int chars = 0;
    int punct = 0;
    int others = 0;

    cin.get(ch);
    while (ch != '@')
    {
        if(isalpha(ch))
            chars++;
        else if(isspace(ch))
            whitespace++;
        else if(isdigit(ch))
            digits++;
        else if(ispunct(ch))
            punct++;
        else
            others++;
        cin.get(ch);
    }
    cout << chars << " letters, "
         <<whitespace <<" whitespace, "
         << digits << " digits, "
         << punct << " punctuations, "
         << others << " others.\n";
    return 0;
}
/*  isalnum()       如果是字母数字,返回true
 *  isalpha()       字母
 *  iscntrl()       控制字符
 *  isdigit()       数字(0-9)
 *  isgraph()       除空格之外的打印字符
 *  islower()       小写字母
 *  isprint()       打印字符(包括空格)
 *  ispunct()       标点符号
 *  isspace()       标准空白字符,例如空格,进纸,换行,回车,水平制表符或者垂直制表符
 *  isupper()       大写字母
 *  isxdigit()      十六进制数字
 *  tolower()       如果参数是大写字符则,返回其小写,否则返回该参数
 *  toupper()       如果参数是小写字符则,返回其大写,否则返回该参数
*/
